<?php
namespace app\admin\model;


use think\Db;

class AuthModel extends BaseModel
{
    protected $table = 'sf_auth';
    public function get_nav_tree($nav_id,$tree = []){
        $where = [];
        $where['id'] = $nav_id;
        $auth = Db::table($this->table)->where($where)->order('id desc')->find();
        $tree[] = $auth;
        if($auth['nav_pid'] == 0){
            return $tree;
        }else{
            return $this->get_nav_tree($auth['nav_pid'],$tree);
        }
    }

    public function check_child_exist($id){
        return $this->where(['pid'=>$id])->whereOr(['nav_pid'=>$id])->find();
    }
}
